//
//  SleepModel.h
//  project
//
//  Created by 黄建华 on 2018/2/5.
//  Copyright © 2018年 黄建华. All rights reserved.
//

#import <Foundation/Foundation.h>
// 每次睡眠模型
@interface SleepSubModel : NSObject
@property (nonatomic, strong) NSString  *subdate;        // 每次睡眠日期
@property (nonatomic, strong) NSString  *substartTime;   // 每次睡眠开始时间
@property (nonatomic, strong) NSString  *subendTime;     // 每次睡眠醒来时间
@property (nonatomic, assign) NSInteger subdeep;         // 深睡时长
@property (nonatomic, assign) NSInteger sublight;        // 浅睡时长
@property (nonatomic, assign) NSInteger subsober;        // 清醒时长
@property (nonatomic, assign) NSInteger subtotalduration;// 睡眠总时长 (深睡 + 浅睡 + 清醒）
@property (nonatomic, assign) NSInteger subeffDuration;  // 有效睡眠时长(深睡 + 浅睡）
@property (nonatomic, assign) float     subCompare;      // 有效睡眠时长 / 睡眠总时长
@property (nonatomic, strong) NSArray   *subsleepData;   // 每次睡眠详情(睡眠状态 加 每段时长）
@end


@interface SleepModel : NSObject
@property (nonatomic, strong) NSString  *user_id;
@property (nonatomic, strong) NSString  *mac;
@property (nonatomic, strong) NSString  *dateString;
@property (nonatomic, assign) BOOL      isSaveAllDay;  // 是否保存了全天

//睡眠
@property (nonatomic, assign) NSInteger      deeps;    // 深睡
@property (nonatomic, assign) NSInteger      lights;   // 浅睡
@property (nonatomic, assign) NSInteger      sobers;   // 清醒
@property (nonatomic, assign) NSInteger      durations; // 睡眠总时长
@property (nonatomic, assign) NSInteger      durationTotal; // 睡眠总时间
@property (nonatomic, assign) NSInteger      effDuration; // 深睡 + 浅睡
@property (nonatomic, assign) BOOL           sleepquality; // 是否达标 (compareEff >0.7)
@property (nonatomic, assign) float          compareEff; // 深睡 + 浅睡 / 睡眠总时间
@property (nonatomic, strong) NSString       *compareQuality;// 睡眠质量
@property (nonatomic, assign) float          compareDeep;
@property (nonatomic, assign) float          compareLight;
@property (nonatomic, assign) float          compareSober;
@property (nonatomic, assign) NSInteger      sleepFinish;
@property (nonatomic, assign) NSInteger      maxDurations;
@property (nonatomic, strong) NSMutableArray *sleepsubArray;   // 每一次睡眠集合

@property (nonatomic, strong) NSString *detailData;    // 详细数据

+ (SleepModel *)initWithDate:(NSDate *)date;
+ (SleepModel *)getSleepModelFromDB; // 获取今天的本地运动
+ (SleepModel *)getSleepModelFromDBWith:(NSDate *)date;
+ (SleepModel *)getSleepModelFromDBWithDayString:(NSString *)string;
- (void)        updateToDBSafely;
// 睡眠大数据
+ (void)updateSleepData:(NSData *)sleepData;
+ (void)sleepTransEnd;

//同步下载数据需要的
- (void)saveToDBByDownload;

@end

